package com.smiletrain.activities;

import com.smiletrain.R;
import com.smiletrain.base.Caso;
import com.smiletrain.util.AdminAlarma;
import com.smiletrain.util.AdminCasos;
import com.smiletrain.util.Constantes;
import com.smiletrain.util.Util;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

public class WellcomeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
        setContentView(R.layout.wellcome_view);
        
        Util.createDirIfNotExists(Constantes.IMAGE_PATH);
        Util.createDirIfNotExists(Constantes.OCCUR_PATH);
        Util.createDirIfNotExists(Constantes.ALARM_PATH);
        Util.createDirIfNotExists(Constantes.ZIP_PATH);
        
        AdminAlarma.instance.loadAlarmas();
        AdminCasos.instance.loadCasos();
        
        Button bNuevoCaso = (Button) findViewById(R.id.bNuevoCaso);
        
        bNuevoCaso.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				buildNewCaso();
				Intent intent = new Intent(WellcomeActivity.this, TipoActivity.class);
				startActivity(intent);
			}
			
		});
        
        Button bMisCasos = (Button) findViewById(R.id.bMisCasos);
        
        bMisCasos.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(WellcomeActivity.this, MisCasosActivity.class);
				startActivity(intent);
			}
			
		});
        
    }
    
    protected void buildNewCaso() {
		Caso c = new Caso();
		int id = AdminCasos.instance.addCaso(c);
		AdminCasos.instance.setCasoActual(id);
	}
    
}